
import java.awt.Graphics;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.List;



/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 *
 * @author Tyulen
 */
class PlotPoint extends Point2D {

    double x;
    double y;
    
    PlotPoint(double x, double y) {
        this.x = x;
        this.y = y;
    }
    
    @Override
    public double getX() {
        return x;
    }

    @Override
    public double getY() {
        return y;
    }

    @Override
    public void setLocation(double x, double y) {
        this.x = x;
        this.y = y;
    }
    
}

public class TempPlotter extends javax.swing.JPanel {

    /**
     * Creates new form TempPlotter
     */
    private List<Point2D> points = new ArrayList<Point2D>();
    private double startX;
    private double xSize;
    private double ySize;
    
    public TempPlotter() {
        initComponents();
    }

    private int toPixelsX(double value) {
        return (int)(value * getWidth() / xSize);
    }
    
    private int toPixelsY(double value) {
        return (int)(-value * getHeight() / ySize + getHeight());
    }
    
    @Override
    protected void paintComponent(Graphics g) {
        for (int i = 1; i < points.size(); i++) {
            g.drawLine(toPixelsX(points.get(i - 1).getX() - startX), 
                    toPixelsY(points.get(i - 1).getY()), 
                    toPixelsX(points.get(i).getX() - startX), 
                    toPixelsY(points.get(i).getY()));
        }
    }
    
    public void setXSize(double value) {
        xSize = value;
    }
    
    public double getXSize() {
        return xSize;
    }
    
    public void setYSize(double value) {
        ySize = value;
    }
    
    public double getYSize() {
        return ySize;
    }
    
    public void addPoint(Point2D point) {
        points.add(point);
        repaint();
    }
    
    public void addMove(double translation) {
        startX += translation;
    }
    
    public void addMoveForward() {
        startX += xSize / 2;
    }
    
    public void addMoveBackward() {
        startX -= xSize / 2;
    }
    
    public double getStartX() {
        return startX;
    }
    
    public double getLastX() {
        return startX + xSize;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setBackground(new java.awt.Color(255, 255, 255));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
